package com.galudisu.handsonic.modules.system.dao;

import com.galudisu.handsonic.modules.system.domain.Role;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.Collection;
import java.util.List;
import java.util.Set;

/**
 * @author Barudisshu
 */
@Repository
public interface RoleDao extends JpaRepository<Role,String> {

    @Query("select r.id from Role r join r.users u where u.username = :username")
    Set<String> findIdSetByUsersUsername(@Param("username") String username);
    @Query("select r.name from Role r where r.id in (?1)")
    List<String> findNamesByContains(Collection<String> roleIds);
}
